From d4959a95c21e20da530a0358f81049e13623d866 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 9 Oct 2021 05:25:05 +0200 Subject: [PATCH] gl: Make sure to set a proper alignment No matter which branch we take, the alignment setting is always the same. --- gdk/gdkglcontext.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c index 196e5fce4d..f719da3aea 100644 --- a/gdk/gdkglcontext.c +++ b/gdk/gdkglcontext.c @@ -298,15 +298,14 @@ gdk_gl_context_upload_texture (GdkGLContext *context, bpp = gdk_memory_format_bytes_per_pixel (data_format); + glPixelStorei (GL_UNPACK_ALIGNMENT, gdk_memory_format_alignment (data_format)); + /* GL_UNPACK_ROW_LENGTH is available on desktop GL, OpenGL ES >= 3.0, or if * the GL_EXT_unpack_subimage extension for OpenGL ES 2.0 is available */ if (stride == width * bpp) { - glPixelStorei (GL_UNPACK_ALIGNMENT, 1); - glTexImage2D (texture_target, 0, gl_internalformat, width, height, 0, gl_format, gl_type, data); - glPixelStorei (GL_UNPACK_ALIGNMENT, 4); } else if (stride % bpp == 0 && (!gdk_gl_context_get_use_es (context) || @@ -325,6 +324,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context, for (i = 0; i < height; i++) glTexSubImage2D (texture_target, 0, 0, i, width, 1, gl_format, gl_type, data + (i * stride)); } + glPixelStorei (GL_UNPACK_ALIGNMENT, 4); g_free (copy); } -- 2.30.2